#define  _CRT_SECURE_NO_WARNINGS


#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int cmp(const void* e1, const void* e2)
{
    return *(int*)e1 - *(int*)e2;
}
int fun(int n)
{
    int i = 0, flag = 1;
    for (i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            flag = 0;
            break;
        }
    }
    return flag;
}
int arr[10000] = { 0 };
int main()
{
    int i = 0, n = 0, m = 0;
    long long temp = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    qsort(arr, n, sizeof(int), cmp);
    temp = arr[n - m] - arr[m - 1];
    if (fun(temp) == 1 && temp > 0)
        printf("YES\n");
    else
        printf("NO\n");
    printf("%lld\n", temp);
    return 0;
}